﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace PlaystationNetworkAPI.Core.US
{
    internal class Parser : Common.Parser
    {
        internal Parser(string htmlCode)
            : base(htmlCode)
        {
            _RegexPattern = Properties.Settings.Default.US_Parser_RegexPattern;
        }

        private string GetValue(string tagName, string attributeName, string attributeValue, string toRemove)
        {
            string outputString = GetInnerText(tagName, attributeName, attributeValue)[0];

            outputString = outputString.Replace(toRemove, string.Empty).Trim();

            return outputString;
        }

        internal int GetLevel()
        {
            int outputInt;

            int.TryParse(GetInnerText("div", "id", "leveltext")[0], out outputInt);

            return outputInt;
        }

        internal int GetProgress()
        {
            int outputInt;

            int.TryParse(GetInnerText("div", "class", "progresstext")[0], out outputInt);

            return outputInt;
        }

        internal int GetBronzeTrohies()
        {
            int outputInt;

            int.TryParse(GetInnerText("div", "class", "text bronze")[0], out outputInt);

            return outputInt;
        }

        internal int GetSilverTrohies()
        {
            int outputInt;

            int.TryParse(GetInnerText("div", "class", "text silver")[0], out outputInt);

            return outputInt;
        }

        internal int GetGoldTrophies()
        {
            int outputInt;

            int.TryParse(GetInnerText("div", "class", "text gold")[0], out outputInt);

            return outputInt;
        }

        internal int GetPlatinumTrophies()
        {
            int outputInt;

            int.TryParse(GetInnerText("div", "class", "text platinum")[0], out outputInt);

            return outputInt;
        }

        internal int GetTotalTrophies()
        {
            int outputInt;

            int.TryParse(GetInnerText("div", "id", "text")[0], out outputInt);

            return outputInt;
        }

        internal string GetPsnId()
        {
            return GetInnerText("div", "id", "id-handle")[0].Trim();
        }
    }
}
